package cn.snowheart.iterator.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * 数组迭代器
 *
 * @author liuwanxiang
 * @version 2019/07/09
 */
public class ListIterator<T> implements Iterator<T> {

    /**
     * 菜单数组
     */
    private List<T> list;
    /**
     * 下标指针位置
     */
    int pos = 0;

    public ListIterator(List<T> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        if (pos >= list.size() || list.get(pos) == null) {
            return false;
        }
        return true;
    }

    @Override
    public T next() {
        return list.get(pos++);
    }
}
